/**
 * 
 */
package fr.xgouchet.wedding.client.event;

import com.google.gwt.event.shared.GwtEvent;

/**
 * Fired whenever the system needs to send a feedback to the user
 * 
 * @author x.gouchet
 * 
 */
public class FeedbackMessageEvent extends GwtEvent<FeedbackMessageEventHandler> {

	/** The Type of GwtEvent */
	public static Type<FeedbackMessageEventHandler> TYPE = new Type<FeedbackMessageEventHandler>();

	/**
	 * Constructor
	 * 
	 * @param message
	 *            the message to give as feedback
	 * @param error
	 *            is feedback an error message (true) or just some info (false)
	 * 
	 */
	public FeedbackMessageEvent(String message, boolean error) {
		mMessage = message;
		mError = error;
	}

	/**
	 * 
	 * @return if feedback an error message (true) or just some info (false)
	 */
	public boolean isError() {
		return mError;
	}

	/**
	 * 
	 * @return the message
	 */
	public String getMessage() {
		return mMessage;
	}

	/**
	 * @see GwtEvent
	 */
	public Type<FeedbackMessageEventHandler> getAssociatedType() {
		return TYPE;
	}

	/**
	 * @see GwtEvent
	 */
	protected void dispatch(FeedbackMessageEventHandler handler) {
		handler.onFeedbackMessage(this);
	}

	/** is the Feedback message an error */
	private final boolean mError;
	
	/** the message itself */
	private final String mMessage;

}
